import 'dart:async';
import 'package:flutter/services.dart';

class MyPlugin {
  static const platform = const MethodChannel('com.zzh.secondflutter.battery');
  Future<String> getBatteryLevel() async {
    String batteryLevel;
    try {
      final int result = await platform.invokeMethod('getBatteryLevel');
      batteryLevel = 'Battery level at $result % .';
    } on PlatformException catch (e) {
      batteryLevel = "Failed to get battery level: '${e.message}'.";
    }
    return batteryLevel;
  }
}